#! /usr/bin/python3
# encoding : utf-8

from DataGen.DataGenerator import DataGenerator


def main():
    base_path = "./"
    persons, recodes, files = DataGenerator(200)
    with open(base_path + "persons.txt", mode="w") as prs:
        prs.write("Uid\t姓名\t出生日期\t电话号码\t住址\t邮政编码\t身高\t体重\t病历\n")
        for i in persons:
            prs.write("{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n".format(i.Uid, i.Name, i.Birthday, i.Phone, i.Address,
                                                                    i.Postcode, i.BodyHeight, i.BodyWeight,
                                                                    "{}".format(i.MedicalRecords).replace(" ", "")))
    with open(base_path + "recodes.txt", mode="w") as rcd:
        rcd.write("Uid\t病人Uid\t诊断日期\t诊断结果\t结果代码\t文件列表\n")
        for i in recodes:
            rcd.write("{}\t{}\t{}\t{}\t{}\t{}\n".format(i.Uid, i.PatientUid, i.DiagnosisDate, i.DiagnosisResult,
                                                        i.DiagnosisResultCode,
                                                        "{}".format(i.FileList).replace(" ", "")))
    with open(base_path + "files.txt", mode="w") as fl:
        fl.write("Uid\t所属病历\t类型\t文件名\t描述\tUrl\n")
        for i in files:
            fl.write("{}\t{}\t{}\t{}\t{}\t{}\n".format(i.Uid, i.RecodeUid, i.Type, i.Name, i.Desc, i.Url))


if __name__ == "__main__":
    main()
